Skip to content

Fix collision between sofdep unloading and hard symbol dependency#1301

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes-sigs:mainfrom
yevgeny-shnaidman:yevgeny/fix-softdep-unload
Jul 2, 2026
Merged

Fix collision between sofdep unloading and hard symbol dependency#1301
kubernetes-prow[bot] merged 1 commit into
kubernetes-sigs:mainfrom
yevgeny-shnaidman:yevgeny/fix-softdep-unload

Conversation

@yevgeny-shnaidman

Copy link
Copy Markdown
Contributor

scenario:
1.KMM Modules needs to load module_a, module_b, module_c
2. module_a has a hard symbol dependency on module_b.
3. modulesLoadingOrder defined as: [module_a, module_b, module_c]

There is no problems when loading. When unloading using softdep, the following happens

  1. module_a is unloaded first
  2. module_b is unloaded automatically, due to hard symbol dependency
  3. modprobe looks at softdep, sees that module_b is unloaded, and does not continue to module_c

This commit changes the Unload flow:

  1. no softdep is created.
  2. modprobe -r ocmmand is provided with the list of modules defined in the modulesLoadingOrder

This way it will go over every module in the command and try to unload it

@netlify

netlify Bot commented Jul 1, 2026

Copy link
Copy Markdown

Deploy Preview for kubernetes-sigs-kmm ready!

Name Link
🔨 Latest commit 9dc420d
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kmm/deploys/6a4635660938fe00087804b4
😎 Deploy Preview https://deploy-preview-1301--kubernetes-sigs-kmm.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yevgeny-shnaidman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot requested review from mresvanis and ybettan July 1, 2026 19:45
@kubernetes-prow kubernetes-prow Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 1, 2026
@yevgeny-shnaidman

Copy link
Copy Markdown
Contributor Author

/assign @ybettan
/assign @TomerNewman

@codecov-commenter

codecov-commenter commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.78%. Comparing base (fa23a9b) to head (9dc420d).
⚠️ Report is 392 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1301      +/-   ##
==========================================
- Coverage   79.09%   73.78%   -5.31%     
==========================================
  Files          51       68      +17     
  Lines        5109     5116       +7     
==========================================
- Hits         4041     3775     -266     
- Misses        882     1169     +287     
+ Partials      186      172      -14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TomerNewman TomerNewman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This way it will go over every module in the command and try to unload it

but if modprobe will do now modprobe -r a b c and when it tries to remove a, b will be removed too, no? so when modprobe will try to remove b it is already gone and because of that fail.

@yevgeny-shnaidman

Copy link
Copy Markdown
Contributor Author

This way it will go over every module in the command and try to unload it

but if modprobe will do now modprobe -r a b c and when it tries to remove a, b will be removed too, no? so when modprobe will try to remove b it is already gone and because of that fail.

in this case modprobe just goes over every module it received in the command line and tries to remove, no matter if it is present or not. In case of softdep the flow is different

Comment thread internal/worker/worker.go Outdated
}
}

w.logger.Info("Unloading module", "name", moduleName)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we already remove multiple modules, the logs will still show that we remove only a single module

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@yevgeny-shnaidman yevgeny-shnaidman force-pushed the yevgeny/fix-softdep-unload branch from e0351cf to 6c423df Compare July 2, 2026 07:15
Comment thread internal/worker/worker.go Outdated
w.logger.Info("Starting unloading", "args", args)

if err := w.mr.Run(ctx, args...); err != nil {
return fmt.Errorf("could not unload module %s: %v", moduleName, err)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also change the log message here since we can unload multiple modules

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread internal/worker/worker.go
}

args = append(args, moduleName)
if len(cfg.Modprobe.ModulesLoadingOrder) > 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in here
we check with ModulesLoadingOrder != nil, in order to be consistent with the code I would change to
cfg.Modprobe.ModulesLoadingOrder != nil

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using len is safer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so lets change it here to be consistent

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@TomerNewman

Copy link
Copy Markdown
Collaborator

/lgtm

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 2, 2026
@TomerNewman

Copy link
Copy Markdown
Collaborator

/unlgtm

@TomerNewman

Copy link
Copy Markdown
Collaborator

/remove-lgtm

@kubernetes-prow kubernetes-prow Bot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 2, 2026
@TomerNewman

Copy link
Copy Markdown
Collaborator

/hold

@kubernetes-prow kubernetes-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 2, 2026
@TomerNewman

Copy link
Copy Markdown
Collaborator

/unhold

I lgtmed accidently

@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 2, 2026
@yevgeny-shnaidman yevgeny-shnaidman force-pushed the yevgeny/fix-softdep-unload branch from 6c423df to d5a9547 Compare July 2, 2026 09:01
scenario:
1.KMM Modules needs to load module_a, module_b, module_c
2. module_a has a hard symbol dependency on module_b.
3. modulesLoadingOrder defined as: [module_a, module_b, module_c]

There is no problems when loading. When unloading using softdep, the following happens
1. module_a is unloaded first
2. module_b is unloaded automatically, due to hard symbol dependency
3. modprobe looks at softdep, sees that module_b is unloaded, and does
   not continue to module_c

This commit changes the Unload flow:
1. no softdep is created.
2. modprobe -r ocmmand is provided with the list of modules defined in
   the modulesLoadingOrder

This way it will go over every module in the command and try to unload
it
@yevgeny-shnaidman yevgeny-shnaidman force-pushed the yevgeny/fix-softdep-unload branch from d5a9547 to 9dc420d Compare July 2, 2026 09:54
@TomerNewman

Copy link
Copy Markdown
Collaborator

/lgtm

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 2, 2026
@kubernetes-prow kubernetes-prow Bot merged commit f17d16d into kubernetes-sigs:main Jul 2, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants